package it.polimi.traveldream.web;

import java.util.ArrayList;

import it.polimi.traveldream.CustompackageDTO;
import it.polimi.traveldream.GestionePacchettoLocal;
import it.polimi.traveldream.GestioneRicercaLocal;
import it.polimi.traveldream.GestioneUtenteLocal;
import it.polimi.traveldream.HotelDTO;
import it.polimi.traveldream.PackageDTO;
import it.polimi.traveldream.TransportDTO;
import it.polimi.traveldream.UtenteDTO;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;

@ManagedBean(name="personalizzazionepacchetto")
@SessionScoped
public class PersonalizzazionePacchettoBean {
	
	@EJB
	private GestionePacchettoLocal  mnu;
	
	@EJB
	private GestioneRicercaLocal gs;
	
	private CustompackageDTO custompackage;
	private int selectedHotel;
	private int selectedVoloAndata;
	private int selectedVoloRitorno;
	private ArrayList<String>selectedEscursioni=new ArrayList<String>();
	private String npersone;
	
	private HotelDTO selectedHoteltmp;
	
	
	public int getSelectedHotel() {
		return selectedHotel;
	}




	public void setSelectedHotel(int selectedHotel) {
		this.selectedHotel = selectedHotel;
	}
	
	
	public int getSelectedVoloAndata() {
		return selectedVoloAndata;
	}


	public void setSelectedVoloAndata(int selectedVoloAndata) {
		this.selectedVoloAndata = selectedVoloAndata;
	}
	
	public int getSelectedVoloRitorno() {
		return selectedVoloRitorno;
	}


	public void setSelectedVoloRitorno(int selectedVoloRitorno) {
		this.selectedVoloRitorno = selectedVoloRitorno;
	}


	public PersonalizzazionePacchettoBean(){
		this.custompackage=new CustompackageDTO();
	}
	

	public void setCustompackage(CustompackageDTO custompackage) {
		this.custompackage = custompackage;
	}


	public CustompackageDTO getCustompackage() {
		return custompackage;
	}
	
	public String crea(int id) {
		
		System.out.print("entrato in crea"+id);
		System.out.print("entrato in crea"+this.npersone);
		
		mnu.salva(selectedHotel,selectedVoloAndata,selectedVoloRitorno,selectedEscursioni,Integer.parseInt(getNpersone()),id);
		System.out.print("ritorno da personalizzazione; redirect pagamento");
		//return "index.xhtml";
		return "formPagamento.xhtml?faces-redirect=true";
	}




	public ArrayList<String> getSelectedEscursioni() {
		return selectedEscursioni;
	}




	public void setSelectedEscursioni(ArrayList<String> selectedEscursioni) {
		this.selectedEscursioni = selectedEscursioni;
	}




	public String getNpersone() {
		return npersone;
	}




	public void setNpersone(String npersone) {
		this.npersone = npersone;
	}
	
	public HotelDTO hotelbyid(int id)
	  {
		return gs.ricercaHotelDTOById(id);
	}
  
	public TransportDTO trasportobyid(int id){
		return gs.ricercaVoloDTOById(id);
	}




	public HotelDTO getSelectedHoteltmp() {
		return selectedHoteltmp;
	}




	public void setSelectedHoteltmp(HotelDTO selectedHoteltmp) {
		this.selectedHoteltmp = selectedHoteltmp;
	}
	
	
}
	
	
		
		
		
	


